/*
 * @Description: // 企业权限相关 API
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-03-13 20:00:31
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-05-13 10:24:23
 */
import createAPI from '@/utils/axios'

const enterprise = {
  // 企业
  enterprise: {
    add: config => createAPI('/admin/v1/enterprise', 'POST', config),
    edit: config => createAPI('/admin/v1/enterprise', 'PUT', config),
    del: id => createAPI('/admin/v1/enterprise/' + id, 'DELETE', {}),

    // 获取企业的部门列表信息
    getDeptList: enterpriseId => createAPI('/admin/v1/enterprise/dept-list?enterprise_id=' + enterpriseId, 'GET', {}),
    // 获取企业的部门的用户列表信息
    getDeptUserSimpleList: config => createAPI('/admin/v1/enterprise/dept-user-simple', 'GET', config),
    // 获取企业的详细信息
    detail: () => createAPI('/admin/v1/enterprise/detail', 'GET', {}),
    // 生成企业进入前端的二维码
    generateQrcode: () => createAPI('/admin/v1/enterprise/generate-qrcode', 'GET', {}),

    // 同步企业用户为管理员
    saveSuperUser: config => createAPI('/admin/v1/enterprise/save-super-user', 'POST', config),
    // 修改基本信息
    updateBasic: config => createAPI('/admin/v1/enterprise/update-basic', 'PUT', config),
  },
  // 部门
  department: {
    add: config => createAPI('/admin/v1/department', 'POST', config),
    edit: config => createAPI('/admin/v1/department', 'PUT', config),
    del: id => createAPI('/admin/v1/department/' + id, 'DELETE', {}),

    // 获取可管理的部门信息
    getDeptList: () => createAPI('/admin/v1/department/dept-list', 'GET', {}),
    // 保存部门信息
    saveDepartment: config => createAPI('/admin/v1/department/save-department', 'POST', config),
    // 保存部门角色信息
    saveRole: config => createAPI('/admin/v1/department/save-role', 'POST', config),
    // 获取部门的树形结构
    getDeptDatas: name => createAPI('/admin/v1/department/dept-tree?name=' + name, 'GET', {}),
    // 同步部门信息
    syncDeptInfo: () => createAPI('/admin/v1/department/sync-dept', 'POST', {}),
    // 获取企业的部门的用户列表信息
    getDeptUserList: deptId => createAPI('/admin/v1/department/dept-user?dept_id=' + deptId, 'GET', {}),
  },

  //渠道信息
  channel: {
    add: config => createAPI('/admin/v1/channel', 'POST', config),
    edit: config => createAPI('/admin/v1/channel', 'PUT', config),
    del: id => createAPI('/admin/v1/channel/' + id, 'DELETE', {}),

    //获取渠道的信息
    cascade: () => createAPI('/admin/v1/channel/cascade', 'GET', {}),
    //获取一级渠道的信息
    getTopChannels: () => createAPI('/admin/v1/channel/top-list', 'GET', {}),
    //获取二级渠道的级联信息
    cascadeSecond: config => createAPI('/admin/v1/channel/cascade-second', 'GET', config),
    //获取参数获取渠道的级联信息
    cascadeThree: config => createAPI('/admin/v1/channel/cascade-three', 'GET', config),
    //生成二维码图片
    generateWxQrcode: channelCode => createAPI('/admin/v1/channel/generate-qrcode?channel_code=' + channelCode, 'GET', {}),
    //生成小程序码图片
    generateMiniQrcode: config => createAPI('/admin/v1/channel/generate-mini-code', 'GET', config),
  },

  //消息配置
  messageConfig: {
    add: config => createAPI('/admin/v1/message-config', 'POST', config),
    edit: config => createAPI('/admin/v1/message-config', 'PUT', config),
    del: id => createAPI('/admin/v1/message-config/' + id, 'DELETE', {}),

    //获取可选参数
    getParams: config => createAPI('/admin/v1/message-config/params', 'GET', config),
  }
}

export default enterprise